using System;
using System.Data;
using System.Collections.Generic;
namespace eTMS.DAO
{
    /********************************BEGIN DiemThiDauVaoDAO****************************************/
    ///<summary>
    /// <para>Author: Auto generated class by CSharp Code Generator v2.0</para>
    /// <para>Date:27/09/2011 53:05:32</para>
    /// <para>Class Name: DiemThiDauVaoDAO</para>
    /// <para>Description: Class access to table DiemThiDauVao in database. Class for coder code here</para>
    ///</summary>


    public partial class DiemThiDauVaoDAO
    {
        public DataSet SelectAllDSByDotThi(int DotThi_ID, string SBD, string TenKH)
        {
            IDbCommand cmd = this.CreateCommand();
            cmd.CommandText = @"SELECT DiemThiDauVao.DiemThiDauVao_ID,DiemThiDauVao.Diem, DiemThiDauVao.MonThi_ID,KhachHangDotThi.KhachHang_ID
                                FROM  DiemThiDauVao INNER JOIN
                                      KhachHangDotThi ON DiemThiDauVao.KhachHangDotThi_ID = KhachHangDotThi.KhachHangDotThi_ID
                                      INNER JOIN KhachHang ON KhachHang.KhachHang_ID=KhachHangDotThi.KhachHang_ID
                                WHERE KhachHangDotThi.DotThi_ID=" + DotThi_ID.ToString();
            if (SBD != null && SBD.Trim().Length > 0)
            {
                cmd.CommandText += " AND KhachHangDotThi.SBD=@SBD";
                this.CreateCommandParameter(cmd, "@SBD", SBD);
            }
            if (TenKH != null && TenKH.Trim().Length > 0)
            {
                cmd.CommandText += " AND (KhachHang.TenKhachHang LIKE '%'+ @TenKH+ '%')";
                this.CreateCommandParameter(cmd, "@TenKH", TenKH);
            }
            return this.SelectDS(cmd);
        }
        public List<DiemThiDauVaoEntity> SelectAllByListKhachHangDotThiMonThi(List<int> LsKhachHangDotThi, int MonThi_ID)
        {
            IDbCommand cmd = this.CreateCommand();
            cmd.CommandText = @"SELECT DiemThiDauVao.DiemThiDauVao_ID,DiemThiDauVao.Diem, DiemThiDauVao.MonThi_ID,KhachHangDotThi.KhachHang_ID
                                FROM  DiemThiDauVao 
                                WHERE KhachHangDotThi.KhachHangDotThi_ID IN("+string.Join(",",LsKhachHangDotThi.ConvertAll<string>(Convert.ToString).ToArray())+") AND MonThi_ID="+MonThi_ID.ToString();
         
            return this.SelectList(cmd);
        }
    }
    /*****************************************************************************************************/
    /**********************************END DiemThiDauVaoDAO*****************************************/
    /*****************************************************************************************************/
}

